Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lib for typetracers #558

Merged
merged 3 commits into from
Jan 22, 2025
Merged

fix: lib for typetracers #558

merged 3 commits into from
Jan 22, 2025

Conversation

pfackeldey
Copy link
Collaborator

This PR fixes scikit-hep/coffea#1195 (the current vector release 1.6.0 is broken for typetracers)

The problem was that numpy (lib) functions were directly called on TypeTracerArrays. Instead, we should've used the corresponding nplike implementation if it exists. This is only implemented for the typetracer backend as all other backends have already a dedicated dispatch mechanism.

In order to ensure we're catching all errors with this I modified tests/backend/test_awkward.py to run every test also for the typetracer backend.

If this PR looks good and gets merged we should make a new release (and maybe yank the previous one?).

Sorry for the inconvenience!

(cc @lgray)

@pfackeldey pfackeldey changed the title Pfackeldey/fix lib for typetracers fix: lib for typetracers Jan 21, 2025
@pfackeldey pfackeldey requested a review from jpivarski January 21, 2025 22:19
@lgray
Copy link

lgray commented Jan 21, 2025

Also Fixes #557

assert ak.all(vec.to_3D(z=1).z == 1)
assert ak.all(vec.to_3D(eta=1).eta == 1)
assert ak.all(vec.to_3D(theta=1).theta == 1)
assert_backend(ak.all(vec.to_3D(z=1).z == 1), True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be a lot clearer if these were just inside an if backend == "cpu" block? This really hides what's happening and that it's a simi-no-op? Though I guess it's still computing them, it's just not checking to see if it's true? Could it be equal to a backend == "cpu" constant or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the typetracer backend I want the expressions still be computed, but we can't compare it to numerical values, which is why the assertion is essentially a no-op. This is to make sure that the computation does not fail for the typetracer backend (without checking its result).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to compare the ak.forms.Form in the typetracer case, but that's kind of already checked generously in awkward-array itself - so not really useful.
So this is just to make sure a vector computation does not fail for the typetracer backend.

@lgray
Copy link

lgray commented Jan 22, 2025

@Saransh-cpp could you please take a look at this - 1.6.0 doesn't really work for typetracers in a way that results in crashes. We may want to yank it.

@Saransh-cpp
Copy link
Member

The release on PyPI can be yanked by @henryiii or @jpivarski. I can create a v1.6.1 release and add a note on the v1.6 release as soon as this PR is merged.

@henryiii henryiii merged commit 96e71b3 into main Jan 22, 2025
18 checks passed
@henryiii henryiii deleted the pfackeldey/fix_lib_for_typetracers branch January 22, 2025 20:40
@henryiii
Copy link
Member

Yanked 1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants